package com.example.hangzhou.welbeing.mytestdemoapp.designPatterns.Iterator.model;

import com.example.hangzhou.welbeing.mytestdemoapp.designPatterns.Iterator.inter.Container;
import com.example.hangzhou.welbeing.mytestdemoapp.designPatterns.Iterator.inter.Iterator;

/**
 * 杭州惟君医疗科技有限公司14
 * Created by 20433 on 2018/5/18
 *
 * @desc 东风山河绿，春已不折柳，繁花看不尽，处处惹人留
 * @desc 佛祖镇楼，bug辟容易
 */

public class NameRepository implements Container {
    public String names[] = {"Robert" , "John" ,"Julie" , "Lora"};

    @Override
    public Iterator getIterator() {
        return new NameIterator();
    }
    public class NameIterator implements Iterator{
        int index;

        @Override
        public boolean hasNext() {
            if(index < names.length){
                return true;
            }
            return false;
        }

        @Override
        public Object next() {
            if(this.hasNext()){
                return names[index++];
            }
            return null;
        }
    }
}
